package com.itheima.dubbo.mysql.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itheima.commons.pojo.entity.UserInfos;
import com.itheima.dubbo.interfaces.UserInfosApi;
import com.itheima.dubbo.mysql.mapper.UserInfosMapper;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author yaohu
 * @date 2021/12/5
 * @Version 1.0
 * @describe
 */
@Service
public class UserInfosApiImpl implements UserInfosApi {

    @Autowired
    private UserInfosMapper userInfosMapper;


    @Override
    public UserInfos findUserInfosByUserId(Long userId) {
        return userInfosMapper.selectOne(Wrappers.lambdaQuery(UserInfos.class).eq(UserInfos::getUserId, userId));
    }

    /**
     * 统计用户数
     * @return
     */
    @Override
    public Integer queryUserInfosCount() {

        Integer count = userInfosMapper.selectCount(null);
        return count;
    }
}
